package com.zuikaku.nettychat.service.impl;

import com.zuikaku.nettychat.dao.ChatMapper;
import com.zuikaku.nettychat.pojo.Chat;
import com.zuikaku.nettychat.service.ChatService;
import com.zuikaku.nettychat.vo.ChatVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ChatServiceImpl implements ChatService {

    @Resource
    private ChatMapper chatMapper;

    @Override
    public List<Chat> selectAll() {
        return chatMapper.selectAll();
    }

    @Override
    public List<ChatVO> getChatVOByUserId(Integer userId) {
        return chatMapper.getChatVOByUserId(userId);
    }

    @Override
    public ChatVO selectChatVOByBothId(int currentUserId, int opponentId) {
        return chatMapper.selectChatVOByBothId(currentUserId,opponentId);
    }

    @Override
    public ChatVO selectChatVOByPKForSender(Integer chatId) {
        return chatMapper.selectChatVOByPKForSender(chatId);
    }

    @Override
    public Chat selectChatByPK(int chatId) {
        return chatMapper.selectByPrimaryKey(chatId);
    }

    @Override
    public int updateChatByChat(Chat chat) {
        return chatMapper.updateByPrimaryKeySelective(chat);
    }

    @Override
    public int addChatByChat(Chat newChat) {
        return chatMapper.insertSelective(newChat);
    }
}
